<template>
  <div class="o-top-bar">
    <img src="../../assets/top-bar/top_bar_bg.png" alt="" class="bg" />
    <div class="o-title">
      <div class="left">
        <div class="nav-item" :class="{ ['active-nav']: fullPath === '/collectInfo' }"
          @click="handeJump('/collectInfo')">
          <img src="../../assets/top-bar/nav_bg.png" class="nav-bg-num" />
          <div class="nav-text">采集点信息管理</div>
        </div>
        <div class="nav-item" :class="{ ['active-nav']: fullPath === '/sampleInfo' }" @click="handeJump('/sampleInfo')">
          <img src="../../assets/top-bar/nav_bg.png" class="nav-bg-num" />

          <div class="nav-text">样本基本信息管理</div>
        </div>
      </div>
      <div class="center" @click="handeJump('/')">
        树木年轮生态实验室业务子系统
      </div>
      <div class="right">
        <div class="nav-item" :class="{ ['active-nav']: fullPath === '/experimentalProcedure' }"
          @click="handeJump('/experimentalProcedure')">
          <img src="../../assets/top-bar/nav_bg_right.png" class="nav-bg-num" />
          <div class="nav-text">实验流程</div>
        </div>
        <div class="nav-item" :class="{ ['active-nav']: fullPath === '/diagramPreview' }"
          @click="handeJump('/diagramPreview')">
          <img src="../../assets/top-bar/nav_bg_right.png" class="nav-bg-num" />
          <div class="nav-text">树轮成果管理</div>
        </div>
      </div>
    </div>
    <div class="bar-wrap">
      <div class="left">
        <i :class="['iconfont icon-home']" @click="handeJump('/coolHome')" style="
            font-size: 30px;
            color: white;
            cursor: pointer;
            display: inline-block;
            margin-right: 25px;
            margin-top: 10px;
          "></i>
        <i :class="['iconfont icon-setting']" @click="handeJump('/adminManagement')" style="
            font-size: 30px;
            color: white;
            cursor: pointer;
            display: inline-block;
            margin-right: 25px;
            margin-top: 10px;
          "></i>
        <div class="countdown">
          <div class="dateTime">
            <span class="time">{{ time }}</span>
            <span>{{ date }}星期{{ week }}</span>
          </div>
        </div>
      </div>
      <div class="right">
        <!-- <i
          :class="['el-icon-user-solid']"
          @click="handeJump('/adminManagement')"
          style="
            font-size: 36px;
            color: white;
            cursor: pointer;
            display: inline-block;
            margin-right: 25px;
            margin-top: 10px;
          "
        ></i> -->
        <img src="../../assets/top-bar/u392.png"
          style="width: 33px; height: 33px; margin-right: 25px;margin-top: 10px;cursor: pointer; /* 设置鼠标悬停时的样式为指针 */"
          @click="handeJump('/querystatistics')" />
        <!-- <i
          :class="['el-icon-s-data']"
          @click="handeJump('/newSequence')"
          style="
            font-size: 36px;
            color: white;
            cursor: pointer;
            display: inline-block;
            margin-right: 25px;
            margin-top: 10px;
          "
        ></i> -->
        <!-- <el-badge :value="12" class="item"> -->
          <i :class="['el-icon-message-solid']" @click="showMessageIcon" style="
            font-size: 36px;
            color: white;
            cursor: pointer;
            display: inline-block;
            margin-right: 25px;
            margin-top: 10px;
          "></i>
        <!-- </el-badge> -->

        <div class="user" @click="showUserMessage">
          <img src="../../assets/top-bar/nav_user.png"
            style="width: 33px; height: 33px; margin-left: 6px;margin-top: -10px;" />
          <p style="color: white; font-size: 16px;margin-top: 0;margin-right: 20px;">尚华明</p>
        </div>
      </div>
      <!-- <el-dialog
        title=""
        :visible.sync="ismessage"
        :modal="false"
        
        class="right-aligned-dialog"
      >
        <div slot="title" @click="handeJump('/personalsetting')">消息</div>
      </el-dialog> -->
    </div>
    <!-- 消息框 -->
    <div v-if="isMessageIconVisible" class="message-box">
      <div class="message-header">
        <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" background-color="#F5F5F5"
          text-color="#000000" active-text-color="#0000FF">
          <el-menu-item index="1">通知</el-menu-item>
          <el-menu-item index="2">消息</el-menu-item>
          <el-menu-item index="3">工单</el-menu-item>
        </el-menu>
      </div>
      <div class="message-content">

      </div>
    </div>
    <div v-if="isUserMessageVisible" class="user-message-box">
      <UserMessage />
      <!-- <div class="user-message-content">
        
      </div>
      <div class="user-message-footer">
        
      </div> -->
    </div>

  </div>
</template>
<script>
import UserMessage from "../user-message/index.vue";
import dayjs from "dayjs";
export default {
  name: "OTopBar",
  components: {
    UserMessage,
  },
  data() {
    return {
      activeIndex2: '1',
      time: dayjs().format("HH:mm:ss"),
      date: dayjs().format("YYYY-MM-DD"),
      curTime: process.env.VUE_APP_UPDATE_TIME,
      fullPath: this.$route.fullPath,
      isMessageIconVisible: false,
      isUserMessageVisible: false,
    };
  },
  computed: {
    week() {
      const days = dayjs().day();
      const week = ["日", "一", "二", "三", "四", "五", "六"];
      return week[days];
    },
  },
  mounted() {
    console.log("----======", this.$routefullPath);
    setInterval(() => {
      this.time = dayjs().format("HH:mm:ss");
    }, 1000);
  },
  watch: {
    $route() {
      // let a = this.getBreadcrumb()
      // console.log('----======')
      this.fullPath = this.$route.fullPath;
    },
  },
  methods: {
    // 跳转
    handeJump(path) {
      console.log("-path");
      if (path === this.fullPath) {
        return;
      }
      this.$router.push({ path: path });
    },
    getBreadcrumb() {
      return this.$route.matched.filter((item) => item.name && item.meta.title);
    },
    // showMessage() {
    //   this.ismessage = !this.ismessage;
    // },
    showMessageIcon() {
      this.isMessageIconVisible = !this.isMessageIconVisible;
    },
    showUserMessage() {
      this.isUserMessageVisible = !this.isUserMessageVisible;
    },
  },
};
</script>
<style lang="scss" scoped>
// .tiem {
//   .el-badge__content {
//     font-size: 8px;
//   }

//   ::v-deep( .el-badge__content.is-fixed) {
//     position: absolute;
//     top: 0px;
//     right: 40px;
//     transform: translateY(-10%) translateX(10%) !important;
//   }
// }

.o-top-bar {
  position: relative;
  width: 100%;
}

.bg {
  display: block;
  width: 100%;
  height: 120px;
}

.o-title {
  position: relative;
  z-index: 2;
}

.bar-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  // align-items: center;
  padding: 32px 20px 0;
  box-sizing: border-box;

  .left {
    display: flex;

    .home {}

    .stting {
      padding: 0 15px;
    }
  }

  .o-icon {
    font-size: 30px;
  }

  .countdown {

    // font-family: 'Impact Normal', 'Impact', sans-serif;
    // font-weight: 400;
    // font-style: normal;
    // font-size: 24px;
    // color: #ffffff;
    .dateTime {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #ffffff;

      span {
        margin: 0;
      }

      .time {
        font-size: 24px;
        margin-left: 10px;
      }
    }
  }

  .right {
    display: flex;

    .o-icon {
      margin-left: 20px;
    }
  }
}

.o-title {
  position: absolute;
  // width: 100%;
  height: 100%;
  z-index: 1;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;

  .left,
  .right {
    display: flex;
    margin-top: 30px;
  }

  .nav-item {
    position: relative;
    font-family: "阿里巴巴普惠体 Medium", "阿里巴巴普惠体", sans-serif;
    font-weight: 500;
    font-style: normal;
    font-size: 18px;
    color: #ffffff;
    padding: 5px 0 0 0;
    cursor: pointer;
    /* 设置鼠标悬停时的样式为指针 */

    text-align: center;

    .nav-text {
      width: 180px;
      height: 34px;
      padding-top: 10px;
      background-image: url("../../assets/top-bar/nav_bg_normal.png");
      background-size: 100% 100%;
      box-sizing: border-box;
    }

    .nav-bg-num {
      position: absolute;

      top: 0;
      width: 111px;
      height: 41px;
    }
  }

  .left {
    .active-nav .nav-text {
      background-image: url("../../assets/top-bar/act_nav_left.png");
    }

    .nav-bg-num {
      left: 10px;
    }
  }

  .right {
    .nav-text {
      background-image: url("../../assets/top-bar/normal_right.png");
      background-size: 100% 100%;
    }

    .nav-bg-num {
      right: 10px;
    }

    .active-nav .nav-text {
      background-image: url("../../assets/top-bar/act_nav_right.png");
    }
  }

  .center {
    word-break: keep-all;
    margin: 10px 150px;
    // width: 590px;
    color: #fff;
    text-shadow: 0px 0px 10px rgba(0, 200, 244, 1);
    font-size: 40px;
    font-weight: 700;
    text-align: center;
    font-family: "庞门正道标题体免费版 Bold", "庞门正道标题体免费版 常规",
      "庞门正道标题体免费版", sans-serif;
  }
}

// .right-aligned-dialog {
//   right: 0; /* 将对话框定位到右侧 */
//   transform: translateX(0); /* 确保不会出现水平偏移 */
// }
// .el-dialog__wrapper right-aligned-dialog{
//   position:fixed;
// 	top:60px;
// 	right:90px;
// }
/* 消息框样式 */
.message-box {
  position: absolute;
  width: 300px;
  height: 400px;
  top: 80px;
  right: 40px;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.user-message-box {
  position: absolute;
  width: 300px;
  height: 280px;
  top: 80px;
  right: 40px;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  border-radius: 25px;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}
</style>
